Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Common import for all qml files
Forum Updated to NodeBB v4.3 + New Features

Common import for all qml files

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
6 Posts 3 Posters 1.3k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    Valerian
    wrote on last edited by
    #1

    Hi All,

    I have been using QML for a while and with every update new components as well as existing component are upgraded.

    This leads to the import statements which appear on top of the header file requiring to be updated as well

    import QtQuick 2.3
    import QtQuick.Controls 1.4
    

    and for earlier version

    import QtQuick 2.0
    

    Is there a way to put them in a common file and import that file to all the qml files so it's easier to maintain?

    Kindly advice

    1 Reply Last reply
    0
    • jpnurmiJ Offline
      jpnurmiJ Offline
      jpnurmi
      wrote on last edited by
      #2

      There is no need to import the new version unless you use any new properties, signals, or methods introduced in the new version. The underlying implementation is almost always the same. Just the new API is revisioned so that it won't be visible unless you import the new version, to avoid any potential conflicts with your existing code.

      V 1 Reply Last reply
      0
      • jpnurmiJ jpnurmi

        There is no need to import the new version unless you use any new properties, signals, or methods introduced in the new version. The underlying implementation is almost always the same. Just the new API is revisioned so that it won't be visible unless you import the new version, to avoid any potential conflicts with your existing code.

        V Offline
        V Offline
        Valerian
        wrote on last edited by
        #3

        @jpnurmi Thanks for the replies.

        I have a lot of qml files and each file has different imports. Is it possible to have them in one location and import that location in all the qml files?

        jpnurmiJ 1 Reply Last reply
        0
        • V Valerian

          @jpnurmi Thanks for the replies.

          I have a lot of qml files and each file has different imports. Is it possible to have them in one location and import that location in all the qml files?

          jpnurmiJ Offline
          jpnurmiJ Offline
          jpnurmi
          wrote on last edited by
          #4

          I'm afraid that is not possible in a sensible way.

          1 Reply Last reply
          0
          • P Offline
            P Offline
            Praveen kk
            wrote on last edited by
            #5

            Yes, you can do it by using '.qrc' files.

            1. Add Qt resource file by right clicking on project explorer.
              ![alt text](0_1472133618096_createQrc.jpg image url)2.

            2.Add all your qml files under this qrc.

            1. import this qrc like this
              "import "qrc:/sampleqrc/""

            all the files under "sampleqrc" will be available where ever you import this.

            V 1 Reply Last reply
            0
            • P Praveen kk

              Yes, you can do it by using '.qrc' files.

              1. Add Qt resource file by right clicking on project explorer.
                ![alt text](0_1472133618096_createQrc.jpg image url)2.

              2.Add all your qml files under this qrc.

              1. import this qrc like this
                "import "qrc:/sampleqrc/""

              all the files under "sampleqrc" will be available where ever you import this.

              V Offline
              V Offline
              Valerian
              wrote on last edited by
              #6

              @Praveen-kk Hi Praveen.

              Let me clear the question

              one file "A" has the following import
              import QtQuick 2.3
              import QtQuick.Controls 1.2

              next file "B" has the following import
              import QtQuick 2.3
              import QtQuick.Window 2.2
              import QtQuick.Controls 1.2
              import QtQuick.Layouts 1.1
              import Watson.Controls 1.0

              I would like a single file "C" with
              import QtQuick 2.3
              import QtQuick.Window 2.2
              import QtQuick.Controls 1.2
              import QtQuick.Layouts 1.1
              import Watson.Controls 1.0

              and import this file "C" in both files "A" and "B".

              Can this be done?

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved